/*
 * $Id: string_size.c,v 1.2 2005-12-11 14:40:25 bacon Exp $
 */

#if defined(__MSTRING)
#include <xp/bas/mstring.h>
#elif defined(__WSTRING)
#include <xp/bas/wstring.h>
#else
#include <xp/bas/string.h>
#endif

xp_size_t xp_strlen (const xp_char_t* str)
{
	const xp_char_t* p = str;
	while (*p != XP_CHAR('\0')) p++;
	return p - str;
}

xp_size_t xp_strlenn (const xp_char_t* str, xp_size_t max)
{
	const xp_char_t* p = str;
	while (*p != XP_CHAR('\0') && max > 0) { p++; max--; }
	return p - str;
}

xp_size_t xp_strsize (const xp_char_t* str)
{
	const xp_char_t* p = str;
	while (*p != XP_CHAR('\0')) p++;
	return p - str + 1;
}

xp_size_t xp_strsizen (const xp_char_t* str, xp_size_t max)
{
	const xp_char_t* p = str;
	while (max > 0) {
		if (*p == XP_CHAR('\0')) return p - str + 1;
		p++; max--;
	}
	return p - str;
}

